package com.genius.action;

import java.util.Date;
import java.util.List;

import com.genius.core.manager.StudentManager;
import com.genius.model.Student;
import com.opensymphony.xwork.ActionSupport;

public class StudentAction extends ActionSupport
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    private String studentId = null;

    private Student student = null;
    
    StudentManager studentManager = null;
    
    private List studentPaymentList = null;
    
    private List studentLevelList = null;
    
    private String mode = null;
    
    /**
     * @return Returns the mode.
     */
    public String getMode()
    {
        return mode;
    }

    /**
     * @param mode The mode to set.
     */
    public void setMode(String mode)
    {
        this.mode = mode;
    }

    /**
     * @return Returns the studentPaymentList.
     */
    public List getStudentPaymentList()
    {
        return studentPaymentList;
    }

    /**
     * @param studentPaymentList The studentPaymentList to set.
     */
    public void setStudentPaymentList(List studentPaymentList)
    {
        this.studentPaymentList = studentPaymentList;
    }

    /**
     * @return Returns the student.
     */
    public Student getStudent()
    {
        return student;
    }

    /**
     * @param student The student to set.
     */
    public void setStudent(Student student)
    {
        this.student = student;
    }

    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String showAddStudentForm() throws Exception
    {
        this.student = new Student();
        student.setDateOfAddmission(new Date());
        
        //Returns page with student entry form
        return this.SUCCESS;
    }
    
    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String addStudent() throws Exception
    {
        // Add new student to database.
        studentManager.createStudent(student);
        return this.SUCCESS;
    }

    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String viewStudent() throws Exception
    {
        // Add new student to database.
        student = studentManager.getStudent(studentId);
        studentPaymentList = studentManager.getStudentPaymentDetails(studentId);
        return this.SUCCESS;
    }

    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String editStudentDetails() throws Exception
    {
        // Add new student to database.
        student = studentManager.getStudent(studentId);
        mode = "E";
        return this.SUCCESS;
    }

    /**
     * @return Returns the studentManager.
     */
    public StudentManager getStudentManager()
    {
        return studentManager;
    }

    /**
     * @param studentManager The studentManager to set.
     */
    public void setStudentManager(StudentManager studentManager)
    {
        this.studentManager = studentManager;
    }

    /**
     * @return Returns the studentId.
     */
    public String getStudentId()
    {
        return studentId;
    }

    /**
     * @param studentId The studentId to set.
     */
    public void setStudentId(String studentId)
    {
        this.studentId = studentId;
    }

    /**
     * @return Returns the studentLevelList.
     */
    public List getStudentLevelList()
    {
        return studentLevelList;
    }

    /**
     * @param studentLevelList The studentLevelList to set.
     */
    public void setStudentLevelList(List studentLevelList)
    {
        this.studentLevelList = studentLevelList;
    }

    
        
    
}
